package com.wanhe.base.model.disgn;


import com.wanhe.base.util.ObjectUtil;

/**
 * 单个菜品项目的数据模型
 * <p/>
 * Created by Administrator on 2016/5/19.
 */
public class FoodItemViewModel {

    private static final String HIT_TYPE = "hit";
    private static final String PRICE1_TYPE = "price1";
    private static final String PRICE2_TYPE = "price2";
    private static final String PLUS_TYPE = "plus";

    //2016-08-09新增类型
    private static final String NAME_TYPE = "nametxt";
    private static final String DESC_TYPE = "desc";
    private static final String CUST_TYPE = "txt1";


    /**
     * id : ddfa2ca5-21e3-43bc-be37-d4e5c22ab19c
     * name : 海鲜贝贝郭
     * hit : {"left":-0.27943605122579407,"top":-0.3289149694743871,"width":0.21022727272727273,"height":0.20454545454545456,"color":"#000","text":"海鲜贝贝郭"}
     * price1 : {"left":-0.006731136125155034,"top":-0.2127611370790804,"width":"auto","height":0.02130681818181818,"color":"","text":"99"}
     * price2 : {"left":0.0994318181818182,"top":-0.2116477272727273,"width":"auto","height":0.02130681818181818,"color":"","text":"66"}
     * plus : {"left":-0.007345225603357817,"top":-0.1783706357912811,"width":0.1534090909090909,"height":0.03835227272727273,"color":"#000","text":"1"}
     */

    private String id;
    private String name;

    private ViewModel hit;
    private ViewModel price1;
    private ViewModel price2;
    private ViewModel plus;

    //2016-08-09 添加三个文本域
    private ViewModel nametxt;
    private ViewModel desc;
    private ViewModel txt1;

    public String realPageTypeID;   //控件所在页面正真的菜品类型
    public String realPageTypeID2;   //控件所在页面正真的菜品类型

    public ViewModel getNametxt() {
        if (ObjectUtil.checkObject(nametxt)) {
            nametxt.type = ViewModel.VIEW_TYPE_NAME;
            nametxt.id = id;
            return nametxt;
        }
        return null;
    }

    public ViewModel getDesc() {
        if (ObjectUtil.checkObject(desc)) {
            desc.type = ViewModel.VIEW_TYPE_DESC;
            desc.id = id;
            return desc;
        }
        return null;
    }

    public ViewModel getTxt1() {
        if (ObjectUtil.checkObject(txt1)) {
            txt1.type = ViewModel.VIEW_TYPE_CUST;
            txt1.id = id;
            return txt1;
        }
        return null;
    }

    public int pageId;

    public ViewModel getHit() {
//        return new Gson().fromJson(this.hit, ViewModel.class);
        if (ObjectUtil.checkObject(hit)) {
            hit.type = ViewModel.VIEW_TYPE_HIT;
            hit.id = id;
            hit.realTypeID = realPageTypeID;
            hit.realTypeID2 = realPageTypeID2;
            return hit;
        }
        return null;
    }

    public ViewModel getPrice1() {
//        return new Gson().fromJson(this.price1, ViewModel.class);
        if (ObjectUtil.checkObject(price1)) {
            price1.type = ViewModel.VIEW_TYPE_PRICE0;
            price1.id = id;
            return price1;
        }
        return null;
    }


    public ViewModel getPrice2() {
//        return new Gson().fromJson(this.price2, ViewModel.class);
        if (ObjectUtil.checkObject(price2)) {
            price2.type = ViewModel.VIEW_TYPE_PRICE1;
            price2.id = id;
            return price2;
        }
        return null;
    }

    public ViewModel getPlus() {
//        return new Gson().fromJson(this.plus, ViewModel.class);
        if (ObjectUtil.checkObject(plus)) {
            plus.type = ViewModel.VIEW_TYPE_PLUS;
            plus.id = id;
            return plus;
        }
        return null;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
